<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 26826
  Date: 2022/5/16
  Time: 10:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="renderer" content="webkit">
    <title></title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/pintuer.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/admin.css">
    <script src="${pageContext.request.contextPath}/js/jquery.js"></script>
    <script src="${pageContext.request.contextPath}/js/pintuer.js"></script>
</head>
<body>
<div class="panel admin-panel margin-top">
    <iframe width='100%' height='100%' style="display: none" src='${pageContext.request.contextPath}/findAll.action'
            id='iframe_list' name='iframe_list'></iframe>
    <div class="panel-head" id="add"><strong><span class="icon-plus-square-o"></span>添加新公司</strong></div>
    <div class="body-content">
        <form method="post" class="form-x">
            <div class="form-group">
                <div class="label" style="width: 100px">
                    <label>请填写公司名称</label>
                </div>
                <div class="field">
                    <input type="text" class="input w50" name="company_name"/>
                    <div class="tips"></div>
                </div>
            </div>
            ${warning}
            <div class="form-group">
                <div class="label" style="width: 100px">
                    <label>请填写公司地址</label>
                </div>
                <div class="field">
                    <input type="text" class="input w50" name="company_address"/>
                </div>
            </div>
            <div class="form-group">
                <div class="label" style="width: 100px">
                    <label>请选择雇员</label>
                </div>
                <div class="field">
                    <textarea name="employee_person" style="width: 100%" readonly="true"></textarea>
                    <button type="button" class="btn btn-link" onclick="person()">添加雇员</button>
                </div>
            </div>
            <div class="form-group">
                <div class="label">
                    <label></label>
                </div>
                <div class="field">
                    <button class="button bg-main icon-check-square-o" type="button" onclick="addPerson()">添加</button>
                </div>
            </div>
        </form>
    </div>
</div>

<script>
    function person(){
        $('#iframe_list').css("display", "").css("position", "absolute").css("z-index", "999");
    }

    function addPerson() {

        const url = "${pageContext.request.contextPath}/appendCompany.action";
        let date = {
            company_name: $("[name='company_name']").val(),
            company_address: $("[name='company_address']").val(),
            employee_person: $("[name='employee_person']").attr("id")
        }
        $.post(url, date, function (data) {
            alert(data)
        })
    }
</script>
</body></html>